<script type="text/javascript">
  (function ($) {
    function trH() {
      var temStr = '';
      for(var i = 0; i < 3; i++){
        temStr += `<td width="210" height="421" style="vertical-align: top;">
                      <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                        <tbody>
                          <tr>
                            <td height="${80 -(i * 40)}"></td>
                          </tr>
                          <tr>${str4}</tr>
                        </tbody>
                      </table>
                    </td>`;
       if(i != 2){
        temStr += ` <td width="15"></td>`;
       }
      }
      return `<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                <tbody>
                  <tr>
                    <td width="20"></td>
                    ${temStr}
                    <td width="20"></td>
                  </tr>
                </tbody>
              </table>`
    }
    function trT() {
      var temStr = '', tempStr2 = str2 + str3;
      for(var i = 0; i < 2; i++){
        if(i == 1){
          tempStr2 = str3 + str2;
        }
        temStr += `<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                  <tbody>
                    <tr>
                      <td width="60"></td>
                      ${tempStr2}
                      <td width="60"></td>
                    </tr>
                  </tbody>
                </table>`;
      }
      return temStr
    }
    function taH(item) {
      return `<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                  <tbody>
                    <tr>
                      <td height="${item}"></td>
                    </tr>
                  </tbody>
                </table>`
    }
    function tdT(item, style1) {
      return `<td style="vertical-align: top;font-family: 'microsoft yahei',Arial, Helvetica,Arial,sans-serif;${style1}">
                <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                  <tbody>
                    <tr>
                      <td height="${item}"></td>
                    </tr>
                    <tr>
                      <td>
                        <a href="#" style="color: #fff; display: block; text-decoration: none; padding:0px;line-height: 20px;margin:0px;">
                          <span style="font-size: 30px; font-weight: bold; ">Xiaomi Redmi Note 4</span>
                          <br>
                          <span style="font-size: 24px;font-weight: normal;">3GB 64GB inglés</span>
                        </a>
                        <a href="#" style="display: block; text-decoration: none; padding-top: 10px;font-size: 24px;color:#f6ff00; line-height: 30px;margin:0px;">
                          <span style="font-size:18px;text-decoration: line-through;color: #fff;">259.99€</span>
                          <br>
                          <span style="font-size: 40px;">234</span>.99€
                          <br>
                          <span style="font-size: 18px; color: #fff; background: #009920; padding: 5px 10px;margin:0px; margin: 10px 0px 0px 0px; display: inline-block;">Comprar &gt;&gt;</span>
                        </a>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </td>`
    }
    var str1_1 = `<a href="#" style="display: block;">
                      <img src="./images/201608293-1.png" alt="Xiaomi Redmi Note 4 3GB 64GB Plata-inglés" style="width: 100%;margin:0px;border:0px;padding:0px;display: block;">
                      <img src="./images/201608293-2.png" alt="Xiaomi Redmi Note 4 3GB 64GB Plata-inglés" style="width: 100%;margin:0px;border:0px;padding:0px;display: block;">
                    </a>`,
        str2 = `<td width="370">
                  <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                    <tbody>
                      <tr>
                        <td height="30"></td>
                      </tr>
                      <tr>
                        <td height="191" style="background:#f3aa25">
                          <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                            <tbody>
                              <tr>
                                <td width="30"></td>
                                <td style="font-family: 'microsoft yahei',Arial, Helvetica,Arial,sans-serif;">
                                  <a href="#" style="text-decoration: none;display: block;">
                                    <font style="font-size:23px;color:#c40000;font-weight:bold;line-height: 30px;display: block;">
                                      Original Reaccondicionado
                                      <br>
                                      <span style="font-size: 30px;">iPhone 6 64GB</span>
                                    </font>
                                    <font style="font-size: 24px; color: #c40000; display: block;text-align: left; line-height: 30px; padding: 15px 0px 0px 0px;">
                                      <span style="font-size:18px;color:#fff;text-decoration: line-through;">429.99€</span>
                                      <span style="font-size:35px;">339</span>.99€
                                      <span style="font-size: 16px; color: #fff; padding: 0px; margin:0px; display: block;text-align: left;">Comprar &gt;&gt;</span>
                                    </font>
                                  </a>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </td>
                      </tr>
                      <tr>
                        <td height="30"></td>
                      </tr>
                    </tbody>
                  </table>
                </td>`,
        str3 = `<td width="200" style="background:#fff;">
                  <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                    <tbody>
                      <tr>
                        <td width="15"></td>
                        <td>
                          <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                            <tbody>
                              <tr>
                                <td height="20"></td>
                              </tr>
                              <tr>
                                <td>${str1_1}</td>
                              </tr>
                              <tr>
                                <td height="10"></td>
                              </tr>
                            </tbody>
                          </table>
                        </td>
                        <td width="15"></td>
                      </tr>
                    </tbody>
                  </table>
                </td>`,
        str4 = `<td width="210" height="330" style="vertical-align: top; background: url(./images/201609236.png) no-repeat center top;">
                  <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                    <tbody>
                      <tr>
                        <td height="10"></td>
                      </tr>
                      <tr>
                        <td>
                          <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                            <tbody>
                              <tr>
                                <td width="45"></td>
                                <td>${str1_1}</td>
                                <td width="45"></td>
                              </tr>
                            </tbody>
                          </table>
                          ${taH('15')}
                          
                          <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                            <tbody>
                              <tr>
                                <td style="font-family: 'microsoft yahei',Arial, Helvetica,Arial,sans-serif;text-align: center; ">
                                  <a href="#" style="text-decoration: none; color: #000; display: block; padding:0px;margin:0px;">
                                    <span style="font-size: 14px;line-height: 18px; "> XIAOMI MI 4S
                                      <br>3GB 64GB</span>
                                    <font style="font-size: 24px; color: #ff4302; display: block; line-height: 25px; padding: 0px;margin:10px 0px 6px 0px;">
                                      <span style="font-size:18px;color:#666;text-decoration: line-through;">329.99€</span>
                                      <br>
                                      <span style="font-size:35px;">289</span>.99€
                                    </font>
                                    <span style="font-size: 14px; color: #ff4302; padding: 0px; margin: 0px; display: block;">Comprar &gt;&gt;</span>
                                  </a>
                                </td>
                                <td width="40"></td>
                              </tr>
                            </tbody>
                          </table>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                </td>`
        str5 = `<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                  <tbody>
                    <tr>
                      <td width="60"></td>
                      <td style="vertical-align: top;">${str1_1}</td>
                      <td width="40"></td>
                      ${tdT('50', '')}
                    </tr>
                  </tbody>
                </table>`;
    var str10 = `<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" style="background:#ff561b;">
                    <tbody>
                      <tr>
                        <td style="vertical-align: top;background: url(./images/201609231.jpg) no-repeat center top #FF4303;">
                          ${taH('30') + str5}
                          <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                            <tbody>
                              <tr>
                                ${tdT('20','text-align: right;')}
                                <td width="20"></td>
                                <td style="vertical-align: top;width:165px;">${str1_1}</td>
                                <td width="40"></td>
                              </tr>
                            </tbody>
                          </table>
                          ${str5 + trH() + trT() + taH('20')}
                          <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                            <tbody>
                              <tr>
                                <td width="20"></td>
                                ${str4}
                                <td width="15"></td>
                                ${str4}
                                <td width="15"></td>
                                ${str4}
                                <td width="20"></td>            
                              </tr>
                            </tbody>
                          </table>
                          ${taH('30')}
                        </td>
                      </tr>
                    </tbody>
                  </table>`;
    $("#main").prepend(str10);
  })(jQuery);
</script>